<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2-XMLHttpRequest_参数</title>
</head>

<body>
  <p class="city-p"></p>
  <script>
    /* 
      目标：使用 xhr 携带查询参数，展示某个省下属的城市列表

    */
   const xhr = new XMLHttpRequest()
   xhr.open('get','http://hmajax.itheima.net/api/city?pname=湖南省')
    xhr.addEventListener('loadend',() =>{
      console.log(xhr.response);
      const data = JSON.parse(xhr.response)
      console.log(data);
      document.querySelector('.city-p').innerHTML = data.list.join('<br>')  //数组转字符串
    })

    xhr.send()
 </script>
</body>
</html>